#include<stdio.h>
#define M 5
#define N 100

int main()
{
    int a[M]={10,8,8,6,0},b[N]={1,2,3,4,5,6,7,8,9,10,0};
    int lena=4,lenb=10,flag=0;
    int *pa=a,*pb=b,*temp;
    while(*pa){
        pb=b;
        if((*pa)<=(*pb)){
            temp=pb+lenb;
            while(temp){
                *(temp)=*(temp-1);
                temp--;
            }
            *pb=*pa;
            lenb++;
            pa++;
            continue;
        }
        if(*pa>=*(pb+lenb-1)){
            *(pb+lenb)=*(pa);
            lenb++;
            pa++;
            continue;
        }
        while(*pb){
            if((*pb)<=(*pa)&&*(pb+1)>(*pa)){
                temp=pb+lenb;
                while(temp){
                    *(temp)=*(temp-1);
                    if(temp==pb) break;
                    temp--;
                }
                lenb++;
                *pb=*pa;
                break;
            }
            pb++;
        }
        pa++;
    }
    *(pb+lenb)=0;
    pb=b;
    while(*pb){
        printf("%d ",*(pb));   //最后一个空格未能单独考虑
        pb++;
    }
}